﻿using UnityEngine;
using System.Collections;

public class OInput{

    public static readonly OInput singleton = new OInput();

    public int _move_ws = 0;
    public int _move_ad = 0;

    public float _mouse_x = 0;
    public float _mouse_y = 0;
    public float _mouse_scroll = 0;

    // Call before all other logic update
	public void Update ()
    {
        Clear();

        UpdateWASD();
        UpdateMouse();
	}

    void Clear()
    {
        _move_ws = _move_ad = 0;
        _mouse_x = _mouse_y = _mouse_scroll = 0;
    }

    void UpdateWASD()
    {
        if (Input.GetKey(KeyCode.W)) _move_ws++;
        if (Input.GetKey(KeyCode.S)) _move_ws--;
        if (Input.GetKey(KeyCode.A)) _move_ad--;
        if (Input.GetKey(KeyCode.D)) _move_ad++;
    }

    void UpdateMouse()
    {
        if (Input.GetMouseButton(0))
        {
            _mouse_x = Input.GetAxis("Mouse X");
            _mouse_y = Input.GetAxis("Mouse Y");
        }
        _mouse_scroll = Input.GetAxis("Mouse ScrollWheel");
    }
}
